package test1;

      public class PersonSortable  implements Comparable<PersonSortable>{
			private String name;
    		private int age;
    		

    		public PersonSortable() {
    			this.name=name;
    			this.age = age;
    		}

			public int getAge() {
    			return age;
    		}
    		public String getName() {
    			return name;
    		}

    		
    		public void run(){
    			System.out.println("run!");
    		}
    		
    		public void eat(){
    			System.out.println("eat!");
    		}
  
  	
    	@Override
		public int compareTo(PersonSortable o) {
			int x=this.getName().compareTo(o.getName());
			if(x!=0)
				return x;
			return this.getAge()-o.getAge();
		}
		
		@Override
	     public String toString() {
	    	    return "Person [name=" + getName() + ", age=" + age + "]";
	    		}

		public void setName(String name) {
			this.name = name;
		}
	    	

	}


